<div>
    <div class="col-lg-12">
        <div class="panel panel-default">
            <div class="panel-body">
                <div class="col-lg-3">
                    <input class="form-control" type="text" name="textfield" id="textfield" value="请选择EXCEL格式文件" autocomplete="off" readonly="readonly">
                </div>
                <div class="search_right_button">
                    <input type="file" name="file" style="display: none;">
                    <button class="btn btn-primary" id="upload_excel">核销优惠券</button>
                </div>
            </div>
            <div class="panel-body">
                <section id="no-more-tables">
                    <table class="table table-bordered table-striped table-condensed cf">
                        <thead class="cf">
                        <tr>
                            <td>序号</td>
                            <td>状态</td>
                            <td>是否线下使用</td>
                            <td>奖品码</td>
                            <td>时间</td>
                        </tr>
                        </thead>
                        <tbody>
                        <?php
                        $i = ($this->now - 1) * $this->size + 1;
                        foreach ($this->list_result as $_info) { ?>
                            <tr>
                                <input type="hidden" name="id[]" value="<?php echo $_info['id'] ?>">
                                <td data-title="id"><?php echo $i++; ?></td>
                                <td data-title="状态"><?php echo \Orm\Coupon\CouponClass::getIsUseList($_info['is_use']); ?></td>
                                <td data-title="是否线下使用"><?php echo \Orm\Coupon\CouponClass::getIsStatusList($_info['status']); ?></td>
                                <td data-title="奖品码"><?php echo $_info['code']; ?></td>
                                <td data-title="时间"><?php echo $_info['insert_time']; ?></td>
                            </tr>
                        <?php } ?>
                        </tbody>
                    </table>
                    <?php echo $this->pageStr; ?>
                </section>
            </div>
        </div>
    </div>
</div>
<script>
    $('input[name=textfield]').click(function(){
        $('input:file').click();
    });
    $('#upload_excel').click(function(){
        if ($('input:file')[0].files[0] == undefined) {
            alert('请选择需要上传的文件');
            return;
        }
        var formData = new FormData();
        formData.append('inputExcel', $('input:file')[0].files[0]);
        var index = layer.msg('正在核销，亲稍等!.....', {icon: 16,shade: 0.01,time:200000000});
        $.ajax({
            url: '/coupon/excel' ,
            type: 'POST',
            data: formData,
            dataType: 'json',
            async: false,
            cache: false,
            contentType: false,
            processData: false,
            success: function (res) {
                if (res.code == 200) {
                    layer.msg('核销成功!');
                    window.location.reload();
                } else {
                    layer.msg('核销失败!');
                    layer.close(index);
                }
            },
            error: function (res) {
                layer.msg('核销失败!');
                layer.close(index);
            }
        });
    });
</script>